#include "Config.h"
#include "Constants.h"

#include <exception>
#include <cstddef>
#include <log4cpp/Category.hh>


namespace Configuration {

log4cpp::Category& logger =
                  log4cpp::Category::getInstance(std::string(SERVER_LOGGER));

Config* Config::_Config = nullptr;

Config::Config(const std::string& configFileName):_fileName(configFileName) {

}

Config::~Config(){

}


void Config::read(){

}

void Config::reload(){

}

Config* Config::getConfig(const std::string& fileName) {


  logger.debug("Config::getConfig->In");

  if (_Config != nullptr)
    return _Config;
  else {
    try {
      _Config = new Config(fileName);
      _Config->read();
      return _Config;
    }
    catch(std::exception& ex) {
      std::string msg( __func__);//+ex.what();

      logger.debug("Config::getConfig" + msg);
    }
  }

  return nullptr;
}

}
